
/*
===============================================================================
                    EntitySpaces Studio by EntitySpaces, LLC
             Persistence Layer and Business Objects for Microsoft .NET
             EntitySpaces(TM) is a legal trademark of EntitySpaces, LLC
                          http://www.entityspaces.net
===============================================================================
EntitySpaces Version : 2012.1.0930.0
EntitySpaces Driver  : SQL
Date Generated       : 2016/10/14 0:44:44
===============================================================================
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using System.Data;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

using EntitySpaces.Core;
using EntitySpaces.Interfaces;
using EntitySpaces.DynamicQuery;



namespace yncTech.BusinessObjects
{
	/// <summary>
	/// Encapsulates the 'Fin_LendReceipt' table
	/// </summary>

    [DebuggerDisplay("Data = {Debug}")]
	[Serializable]
	[DataContract]
	[KnownType(typeof(FinLendReceipt))]	
	[XmlType("FinLendReceipt")]
	public partial class FinLendReceipt : esFinLendReceipt
	{	
		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden | DebuggerBrowsableState.Never)]
		protected override esEntityDebuggerView[] Debug
		{
			get { return base.Debug; }
		}

		override public esEntity CreateInstance()
		{
			return new FinLendReceipt();
		}
		
		#region Static Quick Access Methods
		static public void Delete(System.Decimal lendReceiptID)
		{
			var obj = new FinLendReceipt();
			obj.LendReceiptID = lendReceiptID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save();
		}

	    static public void Delete(System.Decimal lendReceiptID, esSqlAccessType sqlAccessType)
		{
			var obj = new FinLendReceipt();
			obj.LendReceiptID = lendReceiptID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save(sqlAccessType);
		}
		#endregion

		
					
		
	
	}



    [DebuggerDisplay("Count = {Count}")]
	[Serializable]
	[CollectionDataContract]
	[XmlType("FinLendReceiptCollection")]
	public partial class FinLendReceiptCollection : esFinLendReceiptCollection, IEnumerable<FinLendReceipt>
	{
		public FinLendReceipt FindByPrimaryKey(System.Decimal lendReceiptID)
		{
			return this.SingleOrDefault(e => e.LendReceiptID == lendReceiptID);
		}

		
		
		#region WCF Service Class
		
		[DataContract]
		[KnownType(typeof(FinLendReceipt))]
		public class FinLendReceiptCollectionWCFPacket : esCollectionWCFPacket<FinLendReceiptCollection>
		{
			public static implicit operator FinLendReceiptCollection(FinLendReceiptCollectionWCFPacket packet)
			{
				return packet.Collection;
			}

			public static implicit operator FinLendReceiptCollectionWCFPacket(FinLendReceiptCollection collection)
			{
				return new FinLendReceiptCollectionWCFPacket() { Collection = collection };
			}
		}
		
		#endregion
		
				
	}



    [DebuggerDisplay("Query = {Parse()}")]
	[Serializable]	
	public partial class FinLendReceiptQuery : esFinLendReceiptQuery
	{
        public FinLendReceiptQuery() : this("FinLendReceiptQuery")
		{
		}
		public FinLendReceiptQuery(string joinAlias)
		{
			this.es.JoinAlias = joinAlias;
		}	

		override protected string GetQueryName()
		{
			return "FinLendReceiptQuery";
		}
		
					
	
		#region Explicit Casts
		
		public static explicit operator string(FinLendReceiptQuery query)
		{
			return FinLendReceiptQuery.SerializeHelper.ToXml(query);
		}

		public static explicit operator FinLendReceiptQuery(string query)
		{
			return (FinLendReceiptQuery)FinLendReceiptQuery.SerializeHelper.FromXml(query, typeof(FinLendReceiptQuery));
		}
		
		#endregion		
	}

	[DataContract]
	[Serializable]
	abstract public partial class esFinLendReceipt : esEntity
	{
		public esFinLendReceipt()
		{

		}
		
		#region LoadByPrimaryKey
		public virtual bool LoadByPrimaryKey(System.Decimal lendReceiptID)
		{
			if(this.es.Connection.SqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(lendReceiptID);
			else
				return LoadByPrimaryKeyStoredProcedure(lendReceiptID);
		}

		public virtual bool LoadByPrimaryKey(esSqlAccessType sqlAccessType, System.Decimal lendReceiptID)
		{
			if (sqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(lendReceiptID);
			else
				return LoadByPrimaryKeyStoredProcedure(lendReceiptID);
		}

		private bool LoadByPrimaryKeyDynamic(System.Decimal lendReceiptID)
		{
			FinLendReceiptQuery query = new FinLendReceiptQuery();
			query.Where(query.LendReceiptID == lendReceiptID);
			return this.Load(query);
		}

		private bool LoadByPrimaryKeyStoredProcedure(System.Decimal lendReceiptID)
		{
			esParameters parms = new esParameters();
			parms.Add("LendReceiptID", lendReceiptID);
			return this.Load(esQueryType.StoredProcedure, this.es.spLoadByPrimaryKey, parms);
		}
		#endregion
		
		#region Properties
		
		
		
		/// <summary>
		/// Maps to Fin_LendReceipt.LendReceiptID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? LendReceiptID
		{
			get
			{
				return base.GetSystemDecimal(FinLendReceiptMetadata.ColumnNames.LendReceiptID);
			}
			
			set
			{
				if(base.SetSystemDecimal(FinLendReceiptMetadata.ColumnNames.LendReceiptID, value))
				{
					OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.LendReceiptID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendReceipt.LendID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? LendID
		{
			get
			{
				return base.GetSystemDecimal(FinLendReceiptMetadata.ColumnNames.LendID);
			}
			
			set
			{
				if(base.SetSystemDecimal(FinLendReceiptMetadata.ColumnNames.LendID, value))
				{
					OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.LendID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendReceipt.ReceiptID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? ReceiptID
		{
			get
			{
				return base.GetSystemDecimal(FinLendReceiptMetadata.ColumnNames.ReceiptID);
			}
			
			set
			{
				if(base.SetSystemDecimal(FinLendReceiptMetadata.ColumnNames.ReceiptID, value))
				{
					this._UpToFinReceiptByReceiptID = null;
					this.OnPropertyChanged("UpToFinReceiptByReceiptID");
					OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.ReceiptID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendReceipt.CreatedBy
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CreatedBy
		{
			get
			{
				return base.GetSystemString(FinLendReceiptMetadata.ColumnNames.CreatedBy);
			}
			
			set
			{
				if(base.SetSystemString(FinLendReceiptMetadata.ColumnNames.CreatedBy, value))
				{
					OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.CreatedBy);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendReceipt.CreatedDttm
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? CreatedDttm
		{
			get
			{
				return base.GetSystemDateTime(FinLendReceiptMetadata.ColumnNames.CreatedDttm);
			}
			
			set
			{
				if(base.SetSystemDateTime(FinLendReceiptMetadata.ColumnNames.CreatedDttm, value))
				{
					OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.CreatedDttm);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendReceipt.UpdatedBy
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String UpdatedBy
		{
			get
			{
				return base.GetSystemString(FinLendReceiptMetadata.ColumnNames.UpdatedBy);
			}
			
			set
			{
				if(base.SetSystemString(FinLendReceiptMetadata.ColumnNames.UpdatedBy, value))
				{
					OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.UpdatedBy);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendReceipt.UpdatedDttm
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? UpdatedDttm
		{
			get
			{
				return base.GetSystemDateTime(FinLendReceiptMetadata.ColumnNames.UpdatedDttm);
			}
			
			set
			{
				if(base.SetSystemDateTime(FinLendReceiptMetadata.ColumnNames.UpdatedDttm, value))
				{
					OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.UpdatedDttm);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendReceipt.IsKey
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsKey
		{
			get
			{
				return base.GetSystemBoolean(FinLendReceiptMetadata.ColumnNames.IsKey);
			}
			
			set
			{
				if(base.SetSystemBoolean(FinLendReceiptMetadata.ColumnNames.IsKey, value))
				{
					OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.IsKey);
				}
			}
		}		
		
		[CLSCompliant(false)]
		internal protected FinReceipt _UpToFinReceiptByReceiptID;
		#endregion	

		#region .str() Properties
		
		public override void SetProperties(IDictionary values)
		{
			foreach (string propertyName in values.Keys)
			{
				this.SetProperty(propertyName, values[propertyName]);
			}
		}
		
		public override void SetProperty(string name, object value)
		{
			esColumnMetadata col = this.Meta.Columns.FindByPropertyName(name);
			if (col != null)
			{
				if(value == null || value is System.String)
				{				
					// Use the strongly typed property
					switch (name)
					{							
						case "LendReceiptID": this.str().LendReceiptID = (string)value; break;							
						case "LendID": this.str().LendID = (string)value; break;							
						case "ReceiptID": this.str().ReceiptID = (string)value; break;							
						case "CreatedBy": this.str().CreatedBy = (string)value; break;							
						case "CreatedDttm": this.str().CreatedDttm = (string)value; break;							
						case "UpdatedBy": this.str().UpdatedBy = (string)value; break;							
						case "UpdatedDttm": this.str().UpdatedDttm = (string)value; break;							
						case "IsKey": this.str().IsKey = (string)value; break;
					}
				}
				else
				{
					switch (name)
					{	
						case "LendReceiptID":
						
							if (value == null || value is System.Decimal)
								this.LendReceiptID = (System.Decimal?)value;
								OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.LendReceiptID);
							break;
						
						case "LendID":
						
							if (value == null || value is System.Decimal)
								this.LendID = (System.Decimal?)value;
								OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.LendID);
							break;
						
						case "ReceiptID":
						
							if (value == null || value is System.Decimal)
								this.ReceiptID = (System.Decimal?)value;
								OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.ReceiptID);
							break;
						
						case "CreatedDttm":
						
							if (value == null || value is System.DateTime)
								this.CreatedDttm = (System.DateTime?)value;
								OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.CreatedDttm);
							break;
						
						case "UpdatedDttm":
						
							if (value == null || value is System.DateTime)
								this.UpdatedDttm = (System.DateTime?)value;
								OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.UpdatedDttm);
							break;
						
						case "IsKey":
						
							if (value == null || value is System.Boolean)
								this.IsKey = (System.Boolean?)value;
								OnPropertyChanged(FinLendReceiptMetadata.PropertyNames.IsKey);
							break;
					

						default:
							break;
					}
				}
			}
            else if (this.ContainsColumn(name))
            {
                this.SetColumn(name, value);
            }
			else
			{
				throw new Exception("SetProperty Error: '" + name + "' not found");
			}
		}		

		public esStrings str()
		{
			if (esstrings == null)
			{
				esstrings = new esStrings(this);
			}
			return esstrings;
		}

		sealed public class esStrings
		{
			public esStrings(esFinLendReceipt entity)
			{
				this.entity = entity;
			}
			
	
			public System.String LendReceiptID
			{
				get
				{
					System.Decimal? data = entity.LendReceiptID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.LendReceiptID = null;
					else entity.LendReceiptID = Convert.ToDecimal(value);
				}
			}
				
			public System.String LendID
			{
				get
				{
					System.Decimal? data = entity.LendID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.LendID = null;
					else entity.LendID = Convert.ToDecimal(value);
				}
			}
				
			public System.String ReceiptID
			{
				get
				{
					System.Decimal? data = entity.ReceiptID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ReceiptID = null;
					else entity.ReceiptID = Convert.ToDecimal(value);
				}
			}
				
			public System.String CreatedBy
			{
				get
				{
					System.String data = entity.CreatedBy;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreatedBy = null;
					else entity.CreatedBy = Convert.ToString(value);
				}
			}
				
			public System.String CreatedDttm
			{
				get
				{
					System.DateTime? data = entity.CreatedDttm;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreatedDttm = null;
					else entity.CreatedDttm = Convert.ToDateTime(value);
				}
			}
				
			public System.String UpdatedBy
			{
				get
				{
					System.String data = entity.UpdatedBy;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.UpdatedBy = null;
					else entity.UpdatedBy = Convert.ToString(value);
				}
			}
				
			public System.String UpdatedDttm
			{
				get
				{
					System.DateTime? data = entity.UpdatedDttm;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.UpdatedDttm = null;
					else entity.UpdatedDttm = Convert.ToDateTime(value);
				}
			}
				
			public System.String IsKey
			{
				get
				{
					System.Boolean? data = entity.IsKey;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsKey = null;
					else entity.IsKey = Convert.ToBoolean(value);
				}
			}
			

			private esFinLendReceipt entity;
		}
		
		[NonSerialized]
		private esStrings esstrings;		
		
		#endregion
		
		#region Housekeeping methods

		override protected IMetadata Meta
		{
			get
			{
				return FinLendReceiptMetadata.Meta();
			}
		}

		#endregion		
		
		#region Query Logic

		public FinLendReceiptQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new FinLendReceiptQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(FinLendReceiptQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return this.Query.Load();
		}
		
		protected void InitQuery(FinLendReceiptQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntity)this).Connection;
			}			
		}

		#endregion
		
        [IgnoreDataMember]
		private FinLendReceiptQuery query;		
	}



	[Serializable]
	abstract public partial class esFinLendReceiptCollection : esEntityCollection<FinLendReceipt>
	{
		#region Housekeeping methods
		override protected IMetadata Meta
		{
			get
			{
				return FinLendReceiptMetadata.Meta();
			}
		}

		protected override string GetCollectionName()
		{
			return "FinLendReceiptCollection";
		}

		#endregion		
		
		#region Query Logic

	#if (!WindowsCE)
		[BrowsableAttribute(false)]
	#endif
		public FinLendReceiptQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new FinLendReceiptQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(FinLendReceiptQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return Query.Load();
		}

		override protected esDynamicQuery GetDynamicQuery()
		{
			if (this.query == null)
			{
				this.query = new FinLendReceiptQuery();
				this.InitQuery(query);
			}
			return this.query;
		}

		protected void InitQuery(FinLendReceiptQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntityCollection)this).Connection;
			}			
		}

		protected override void HookupQuery(esDynamicQuery query)
		{
			this.InitQuery((FinLendReceiptQuery)query);
		}

		#endregion
		
		private FinLendReceiptQuery query;
	}



	[Serializable]
	abstract public partial class esFinLendReceiptQuery : esDynamicQuery
	{
		override protected IMetadata Meta
		{
			get
			{
				return FinLendReceiptMetadata.Meta();
			}
		}	
		
		#region QueryItemFromName
		
        protected override esQueryItem QueryItemFromName(string name)
        {
            switch (name)
            {
				case "LendReceiptID": return this.LendReceiptID;
				case "LendID": return this.LendID;
				case "ReceiptID": return this.ReceiptID;
				case "CreatedBy": return this.CreatedBy;
				case "CreatedDttm": return this.CreatedDttm;
				case "UpdatedBy": return this.UpdatedBy;
				case "UpdatedDttm": return this.UpdatedDttm;
				case "IsKey": return this.IsKey;

                default: return null;
            }
        }		
		
		#endregion
		
		#region esQueryItems

		public esQueryItem LendReceiptID
		{
			get { return new esQueryItem(this, FinLendReceiptMetadata.ColumnNames.LendReceiptID, esSystemType.Decimal); }
		} 
		
		public esQueryItem LendID
		{
			get { return new esQueryItem(this, FinLendReceiptMetadata.ColumnNames.LendID, esSystemType.Decimal); }
		} 
		
		public esQueryItem ReceiptID
		{
			get { return new esQueryItem(this, FinLendReceiptMetadata.ColumnNames.ReceiptID, esSystemType.Decimal); }
		} 
		
		public esQueryItem CreatedBy
		{
			get { return new esQueryItem(this, FinLendReceiptMetadata.ColumnNames.CreatedBy, esSystemType.String); }
		} 
		
		public esQueryItem CreatedDttm
		{
			get { return new esQueryItem(this, FinLendReceiptMetadata.ColumnNames.CreatedDttm, esSystemType.DateTime); }
		} 
		
		public esQueryItem UpdatedBy
		{
			get { return new esQueryItem(this, FinLendReceiptMetadata.ColumnNames.UpdatedBy, esSystemType.String); }
		} 
		
		public esQueryItem UpdatedDttm
		{
			get { return new esQueryItem(this, FinLendReceiptMetadata.ColumnNames.UpdatedDttm, esSystemType.DateTime); }
		} 
		
		public esQueryItem IsKey
		{
			get { return new esQueryItem(this, FinLendReceiptMetadata.ColumnNames.IsKey, esSystemType.Boolean); }
		} 
		
		#endregion
		
	}


	
	public partial class FinLendReceipt : esFinLendReceipt
	{

				
		#region UpToFinReceiptByReceiptID - Many To One
		/// <summary>
		/// Many to One
		/// Foreign Key Name - FK_FIN_LEND_REFERENCE_FIN_RECE
		/// </summary>

		[XmlIgnore]
					
		public FinReceipt UpToFinReceiptByReceiptID
		{
			get
			{
				if (this.es.IsLazyLoadDisabled) return null;
				
				if(this._UpToFinReceiptByReceiptID == null && ReceiptID != null)
				{
					this._UpToFinReceiptByReceiptID = new FinReceipt();
					this._UpToFinReceiptByReceiptID.es.Connection.Name = this.es.Connection.Name;
					this.SetPreSave("UpToFinReceiptByReceiptID", this._UpToFinReceiptByReceiptID);
					this._UpToFinReceiptByReceiptID.Query.Where(this._UpToFinReceiptByReceiptID.Query.ReceiptID == this.ReceiptID);
					this._UpToFinReceiptByReceiptID.Query.Load();
				}	
				return this._UpToFinReceiptByReceiptID;
			}
			
			set
			{
				this.RemovePreSave("UpToFinReceiptByReceiptID");
				

				if(value == null)
				{
					this.ReceiptID = null;
					this._UpToFinReceiptByReceiptID = null;
				}
				else
				{
					this.ReceiptID = value.ReceiptID;
					this._UpToFinReceiptByReceiptID = value;
					this.SetPreSave("UpToFinReceiptByReceiptID", this._UpToFinReceiptByReceiptID);
				}
				
			}
		}
		#endregion
		

		
		/// <summary>
		/// Used internally for retrieving AutoIncrementing keys
		/// during hierarchical PreSave.
		/// </summary>
		protected override void ApplyPreSaveKeys()
		{
			if(!this.es.IsDeleted && this._UpToFinReceiptByReceiptID != null)
			{
				this.ReceiptID = this._UpToFinReceiptByReceiptID.ReceiptID;
			}
		}
		
	}
	



	[Serializable]
	public partial class FinLendReceiptMetadata : esMetadata, IMetadata
	{
		#region Protected Constructor
		protected FinLendReceiptMetadata()
		{
			m_columns = new esColumnMetadataCollection();
			esColumnMetadata c;

			c = new esColumnMetadata(FinLendReceiptMetadata.ColumnNames.LendReceiptID, 0, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = FinLendReceiptMetadata.PropertyNames.LendReceiptID;
			c.IsInPrimaryKey = true;
			c.IsAutoIncrement = true;
			c.NumericPrecision = 18;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendReceiptMetadata.ColumnNames.LendID, 1, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = FinLendReceiptMetadata.PropertyNames.LendID;
			c.NumericPrecision = 18;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendReceiptMetadata.ColumnNames.ReceiptID, 2, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = FinLendReceiptMetadata.PropertyNames.ReceiptID;
			c.NumericPrecision = 18;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendReceiptMetadata.ColumnNames.CreatedBy, 3, typeof(System.String), esSystemType.String);
			c.PropertyName = FinLendReceiptMetadata.PropertyNames.CreatedBy;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendReceiptMetadata.ColumnNames.CreatedDttm, 4, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = FinLendReceiptMetadata.PropertyNames.CreatedDttm;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendReceiptMetadata.ColumnNames.UpdatedBy, 5, typeof(System.String), esSystemType.String);
			c.PropertyName = FinLendReceiptMetadata.PropertyNames.UpdatedBy;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendReceiptMetadata.ColumnNames.UpdatedDttm, 6, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = FinLendReceiptMetadata.PropertyNames.UpdatedDttm;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendReceiptMetadata.ColumnNames.IsKey, 7, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = FinLendReceiptMetadata.PropertyNames.IsKey;
			c.HasDefault = true;
			c.Default = @"((0))";
			c.IsNullable = true;
			m_columns.Add(c);
				
		}
		#endregion	
	
		static public FinLendReceiptMetadata Meta()
		{
			return meta;
		}	
		
		public Guid DataID
		{
			get { return base.m_dataID; }
		}	
		
		public bool MultiProviderMode
		{
			get { return false; }
		}		

		public esColumnMetadataCollection Columns
		{
			get	{ return base.m_columns; }
		}
		
		#region ColumnNames
		public class ColumnNames
		{ 
			 public const string LendReceiptID = "LendReceiptID";
			 public const string LendID = "LendID";
			 public const string ReceiptID = "ReceiptID";
			 public const string CreatedBy = "CreatedBy";
			 public const string CreatedDttm = "CreatedDttm";
			 public const string UpdatedBy = "UpdatedBy";
			 public const string UpdatedDttm = "UpdatedDttm";
			 public const string IsKey = "IsKey";
		}
		#endregion	
		
		#region PropertyNames
		public class PropertyNames
		{ 
			 public const string LendReceiptID = "LendReceiptID";
			 public const string LendID = "LendID";
			 public const string ReceiptID = "ReceiptID";
			 public const string CreatedBy = "CreatedBy";
			 public const string CreatedDttm = "CreatedDttm";
			 public const string UpdatedBy = "UpdatedBy";
			 public const string UpdatedDttm = "UpdatedDttm";
			 public const string IsKey = "IsKey";
		}
		#endregion	

		public esProviderSpecificMetadata GetProviderMetadata(string mapName)
		{
			MapToMeta mapMethod = mapDelegates[mapName];

			if (mapMethod != null)
				return mapMethod(mapName);
			else
				return null;
		}
		
		#region MAP esDefault
		
		static private int RegisterDelegateesDefault()
		{
			// This is only executed once per the life of the application
			lock (typeof(FinLendReceiptMetadata))
			{
				if(FinLendReceiptMetadata.mapDelegates == null)
				{
					FinLendReceiptMetadata.mapDelegates = new Dictionary<string,MapToMeta>();
				}
				
				if (FinLendReceiptMetadata.meta == null)
				{
					FinLendReceiptMetadata.meta = new FinLendReceiptMetadata();
				}
				
				MapToMeta mapMethod = new MapToMeta(meta.esDefault);
				mapDelegates.Add("esDefault", mapMethod);
				mapMethod("esDefault");
			}
			return 0;
		}			

		private esProviderSpecificMetadata esDefault(string mapName)
		{
			if(!m_providerMetadataMaps.ContainsKey(mapName))
			{
				esProviderSpecificMetadata meta = new esProviderSpecificMetadata();			


				meta.AddTypeMap("LendReceiptID", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("LendID", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("ReceiptID", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("CreatedBy", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("CreatedDttm", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("UpdatedBy", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("UpdatedDttm", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("IsKey", new esTypeMap("bit", "System.Boolean"));			
				
				
				
				meta.Source = "Fin_LendReceipt";
				meta.Destination = "Fin_LendReceipt";
				
				meta.spInsert = "proc_Fin_LendReceiptInsert";				
				meta.spUpdate = "proc_Fin_LendReceiptUpdate";		
				meta.spDelete = "proc_Fin_LendReceiptDelete";
				meta.spLoadAll = "proc_Fin_LendReceiptLoadAll";
				meta.spLoadByPrimaryKey = "proc_Fin_LendReceiptLoadByPrimaryKey";
				
				this.m_providerMetadataMaps["esDefault"] = meta;
			}
			
			return this.m_providerMetadataMaps["esDefault"];
		}

		#endregion

		static private FinLendReceiptMetadata meta;
		static protected Dictionary<string, MapToMeta> mapDelegates;
		static private int _esDefault = RegisterDelegateesDefault();
	}
}
